/**
 * Copyright (c) 2011 The MITRE Corporation. All rights reserved.
 *
 * NOTICE
 * This software was produced for the U. S. Government
 * under Contract No. FA8721-11-C-0001, and is
 * subject to the Rights in Noncommercial Computer Software
 * and Noncommercial Computer Software Documentation Clause
 * (DFARS) 252.227-7014 (JUN 1995)
 */
package org.mitre.edxl.lib;

import java.util.ArrayList;
import java.util.List;

/**
 * Container for valid-namespaced XML data.
 *
 * @author Danny Gagne
 * @author Rob Gustafson
 * @author Brian Wilkins
 * @author Greg Kern
 */
public class XMLContent {
  List<String> keyXMLContent;
  List<String> embeddedXMLContent;

  /**
   * Initializes a new instance of the XMLContent class.
   */
  public XMLContent() {
    keyXMLContent = new ArrayList<String>();
    embeddedXMLContent = new ArrayList<String>();
  }

  /**
   * Adds a Embedded Content to the Embedded Content list.
   *
   * @param val The new Embedded Content to be added to the list.
   */
  public void addKeyContent(String val) {
    if (keyXMLContent == null) {
      keyXMLContent = new ArrayList<String>();
    }
    keyXMLContent.add(val);
  }

  /**
   * Adds a Embedded Content to the Embedded Content list.
   *
   * @param val The new Embedded Content to be added to the list.
   */
  public void addEmbeddedContent(String val) {
    if (embeddedXMLContent == null) {
      embeddedXMLContent = new ArrayList<String>();
    }
    embeddedXMLContent.add(val);
  }

  /**
   * Get the list of values for the Key XML Content.
   *
   * @return The list of the Key XML Content values.
   */
  public List<String> getKeyXMLContent() {
    return keyXMLContent;
  }

  /**
   * Set the list of the Key XML Content values.
   *
   * @param val The list to set the Key XML Content values to.
   */
  public void setKeyXMLContent(List<String> val) {
    keyXMLContent = val;
  }

  /**
   * Get the list of values for the Embedded XML Content.
   *
   * @return The list of the Embedded XML Content values.
   */
  public List<String> getEmbeddedXMLContent() {
    return embeddedXMLContent;
  }

  /**
   * Set the list of the Embedded XML Content values.
   *
   * @param val The list to set the Embedded XML Content values to.
   */
  public void setEmbeddedXMLContent(List<String> val) {
    embeddedXMLContent = val;
  }

  /**
   * Returns a XML representation of the XMLContent object.
   *
   * @return A String of the XML representation of the XMLContent object.
   */
  public String toXML() {
    String temp = "";

    if (keyXMLContent != null) {
      for (String val : keyXMLContent) {
        temp += "<keyXMLContent>" + val + "</keyXMLContent>";
      }
    }

    if (embeddedXMLContent != null) {
      for (String val : embeddedXMLContent) {
        temp += "<embeddedXMLContent>" + val + "</embeddedXMLContent>";
      }
    }

    return temp;
  }
}
